package Servlet;

import DAO.DAOFactory;
import DAO.TechnicianDAO;
import javabean.Technician;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/pendingTechnician")
public class PendingTechnicianServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8"); // 设置编码
        resp.setCharacterEncoding("UTF-8");
        TechnicianDAO technicianDAO = (TechnicianDAO) DAOFactory.getTechnicianDAOInstance();
        List<Technician> pendingTechnicianList = technicianDAO.getAllPendingTechnicians(); // 获取所有待处理技术人员
        for(Technician technician:pendingTechnicianList){
            System.out.println(technician.getTechnicianID());
        }
        req.setAttribute("pendingTechnicianList", pendingTechnicianList); // 将待处理技术人员列表添加到请求属性中
        req.getRequestDispatcher("pendingTechnician.jsp").forward(req, resp); // 转发请求
    }
}
